/**文章 */

import { JsonController, Authorized, Body, HeaderParam, Get, Post, UseBefore, QueryParam, Params} from 'routing-controllers';
import { RequestLog } from '@/middleware/requestLog'
import { Inject, Service } from 'typedi';
import { EssayServiceImpl } from '@/impl/admin/EssayServiceImpl';
import { JsonResult, msgList, res } from '@/utils/jsonResult';
import { User } from '@/m_res/user'
import {CommentParams } from "@/model/request/Comment";
import config from '@/config'
import { Essayreq ,Essayupdata} from '@/m_req/Essayreq'
import { Token } from '@/m_req/Token'
import { Article } from '@/entity/Article';

interface ddd{
  id:number
}
@Service()
@JsonController(config.setPrefix("admin/essay"))
export class EssayController {

  @Inject()
  EssayServiceImpl!: EssayServiceImpl;

  @Inject()
  json!: JsonResult<any>;  // Promise<res<string>> 
  

  //文章添加
  @Post('/add')
  @UseBefore(RequestLog)
  @Authorized()
  async add(@Body() params:Essayreq, @HeaderParam("token") token: Token):Promise<any>{
     console.log("sdsdsdsdssd",token.user_id)
    return await this.EssayServiceImpl.Essayadd(params,token);
  }

  //文章删除

  @Post('/delete')
  @UseBefore(RequestLog)
  async delete(@Body() params:Article):Promise<any>{
    console.log(params)
   return await this.EssayServiceImpl.Essaydelete(params);
 }

 //文章删除

 @Post('/updata')
 @UseBefore(RequestLog)
 async updata(@Body() params:Essayupdata):Promise<any>{
   console.log("params:",params)
  return await this.EssayServiceImpl.Essayupdata(params);
}

}